/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package supportlearning.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Huy
 */
@Entity
@Table(name = "Course", catalog = "SupportLearningDB", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "Course.findAll", query = "SELECT c FROM Course c"),
    @NamedQuery(name = "Course.findByCourseId", query = "SELECT c FROM Course c WHERE c.courseId = :courseId"),
    @NamedQuery(name = "Course.findByCourseName", query = "SELECT c FROM Course c WHERE c.courseName = :courseName"),
    @NamedQuery(name = "Course.findByDescription", query = "SELECT c FROM Course c WHERE c.description = :description"),
    @NamedQuery(name = "Course.findByDuration", query = "SELECT c FROM Course c WHERE c.duration = :duration")})
public class Course implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "CourseId", nullable = false)
    private Integer courseId;
    @Basic(optional = false)
    @Column(name = "CourseName", nullable = false, length = 50)
    private String courseName;
    @Column(name = "Description", length = 100)
    private String description;
    @Basic(optional = false)
    @Column(name = "Duration", nullable = false, length = 50)
    private String duration;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "course")
    private Collection<CMSClass> cMSClassCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "course")
    private Collection<Semester> semesterCollection;

    public Course() {
    }

    public Course(Integer courseId) {
        this.courseId = courseId;
    }

    public Course(Integer courseId, String courseName, String duration) {
        this.courseId = courseId;
        this.courseName = courseName;
        this.duration = duration;
    }

    public Integer getCourseId() {
        return courseId;
    }

    public void setCourseId(Integer courseId) {
        this.courseId = courseId;
    }

    public String getCourseName() {
        return courseName;
    }

    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDuration() {
        return duration;
    }

    public void setDuration(String duration) {
        this.duration = duration;
    }

    public Collection<CMSClass> getCMSClassCollection() {
        return cMSClassCollection;
    }

    public void setCMSClassCollection(Collection<CMSClass> cMSClassCollection) {
        this.cMSClassCollection = cMSClassCollection;
    }

    public Collection<Semester> getSemesterCollection() {
        return semesterCollection;
    }

    public void setSemesterCollection(Collection<Semester> semesterCollection) {
        this.semesterCollection = semesterCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (courseId != null ? courseId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Course)) {
            return false;
        }
        Course other = (Course) object;
        if ((this.courseId == null && other.courseId != null) || (this.courseId != null && !this.courseId.equals(other.courseId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "supportlearning.entities.Course[courseId=" + courseId + "]";
    }

}
